#+title: Configuración de Gnu Emacs
# +setupfile: ~/Documents/TrabajosMe/GnuFull/OrgMode/PlantillaOrgmodeHtml.txt
# +setupfile: ~/Documents/TrabajosMe/GnuFull/OrgMode/PlantillaOrgmodeLatex.txt

#+BEGIN_VERSE
Mi nueva configuración de Emacs de fecha 201119. Desde que me sumergí en el mundo del software libre[fn:2] no  dejo de aprender y sorprenderme de las grandes potencialidades y el empoderamiento de conocimiento que da a las personas en un mundo mas sumergido en las tecnologías.
#+END_VERSE

#+BEGIN_QUOTE
"Gnu[fn:1] Emacs el editor de los dioses", esta premisa aunque pretenciosa resume la singularidad y la potencia exponencial de sus funcionalidades.
#+END_QUOTE

* Install
Solamente son impresindibles los archivos: init.el y emacsrc.org
#+BEGIN_SRC sh
git clone https://notabug.org/gnuser/GnuEmacs221119.git
#+END_SRC
* Startup
** Mensaje
#+BEGIN_SRC emacs-lisp
(defconst animate-n-steps 3)
(defun emacs-reloaded ()
  (animate-string (concat "; Happy Hacking, Welcome to Gnu the Holy Free System and to Emacs the Editor of the Gods, "
              (substring (emacs-version) 0 16) ".")
          0 0)
  (newline-and-indent)  (newline-and-indent))
(add-hook 'after-init-hook 'emacs-reloaded)
#+END_SRC

** Compilación
#+BEGIN_SRC emacs-lisp
  (setq gc-cons-threshold 10000000)

  ;; Restore after startup
  (add-hook 'after-init-hook
            (lambda ()
              (setq gc-cons-threshold 1000000)
              (message "gc-cons-threshold restored to %S"
                       gc-cons-threshold)))
#+END_SRC

** Init limpio
#+BEGIN_SRC emacs-lisp
  (setq custom-file (make-temp-file "emacs-custom"))
#+END_SRC

* Setup
** Conexión Segura
#+BEGIN_SRC emacs-lisp
(setq network-security-level 'high)
#+END_SRC

** Repositorios
#+BEGIN_SRC emacs-lisp
(setq-default package-check-signature nil)
(setq package-enable-at-startup nil)
    (setq package-archives '(("Gnu Elpa" . "https://elpa.gnu.org/packages/")
                             ("Melpa"    . "https://stable.melpa.org/packages/")
                             ("Org"      . "https://orgmode.org/elpa/")))
;(package-initialize)
#+END_SRC

** Actualiza paquetes
# +BEGIN_SRC emacs-lisp
(package-refresh-contents)
# +END_SRC

** Paquetes
*** Auto-install packages
#+BEGIN_SRC emacs-lisp
(setq my-must-have-packages
  '(
  auto-complete
	autopair
	dracula-theme
	elfeed
	emmet-mode
	emms
	flycheck
	gnu-elpa-keyring-update
	golden-ratio
	google-translate
	guile-scheme
	identica-mode
	ix
	magit
	markdown-mode
	mingus
    org-beautify-theme
	org-pomodoro
	pandoc-mode
	php-mode
	pomidor
	projectile
	ps-ccrypt
	rainbow-mode
	simple-mpc
	slime
	smooth-scrolling
	ssh
	use-package
	web-mode
	which-key
	xclip
	yasnippet
	auctex
  atom-one-dark-theme
  org-bullets
;;exwm
	))

;; install any packages in my-must-have-packages,
;; if they are not installed already http://home.thep.lu.se/~karlf/emacs.html
(let ((refreshed nil))
  (when (not package-archive-contents)
    (package-refresh-contents)
    (setq refreshed t))
  (dolist (pkg my-must-have-packages)
    (when (and (not (package-installed-p pkg))
	       (assoc pkg package-archive-contents))
      (unless refreshed
	(package-refresh-contents)
	(setq refreshed t))
      (package-install pkg))))

(defun package-list-unaccounted-packages ()
  "Like `package-list-packages', but shows only the packages that
  are installed and are not in `my-must-have-packages'.  Useful for
  cleaning out unwanted packages."
  (interactive)
  (package-show-package-list
   (remove-if-not (lambda (x) (and (not (memq x my-must-have-packages))
				   (not (package-built-in-p x))
				   (package-installed-p x)))
		  (mapcar 'car package-archive-contents))))
#+END_SRC

* Apariencia
*** Fullscreen
#+BEGIN_SRC emacs-lisp
(toggle-frame-fullscreen)
#+END_SRC

*** Font
#+BEGIN_SRC emacs-lisp
(custom-set-faces
 '(default ((t (:family "xos4 Terminus" :foundry "xos4" :slant normal :weight normal :height 90 :width normal)))))
#+END_SRC

*** Themes
**** Normal
#+BEGIN_SRC emacs-lisp
;(if (display-graphic-p)
;    (load-theme 'dracula t)
;(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
;(load-theme 'dracula t)
;)

(load-theme 'dracula t)
(defun set-background-for-terminal (&optional frame)
  (or frame (setq frame (selected-frame)))
  "unsets the background color in terminal mode"
  (unless (display-graphic-p frame)
    (set-face-background 'default "unspecified-bg" frame)))
(add-hook 'after-make-frame-functions 'set-background-for-terminal)
(add-hook 'window-setup-hook 'set-background-for-terminal)
#+END_SRC

**** COMMENT Con exwm
# +Begin_SRC emacs-lisp
(load-theme 'dracula t)
(set-foreground-color "#648290")
(set-background-color "#2F3D44")
# +END_SRC

*** Dired formato
#+BEGIN_SRC emacs-lisp
(setq dired-listing-switches "-l")
#+END_SRC

* Configuraciones
** Básicas
*** Ajustar texto
#+BEGIN_SRC emacs-lisp
  (global-visual-line-mode 1)
#+END_SRC

*** Sin decoraciones
#+BEGIN_SRC emacs-lisp
  (tool-bar-mode -1)
  (scroll-bar-mode -1)
#+END_SRC

*** Sin campanilla
#+BEGIN_SRC emacs-lisp
  (setq ring-bell-function 'ignore)
#+END_SRC

*** Salir y o n
#+BEGIN_SRC emacs-lisp
  (defalias 'yes-or-no-p 'y-or-n-p)
#+END_SRC

*** Autocompletado
#+BEGIN_SRC emacs-lisp
(define-globalized-minor-mode real-global-auto-complete-mode
  auto-complete-mode (lambda ()
                       (if (not (minibufferp (current-buffer)))
                         (auto-complete-mode 1))
                       ))
(real-global-auto-complete-mode t)
 ;; (setq auto-complete-mode t)
#+END_SRC

*** Identacion en org-mode
#+BEGIN_SRC emacs-lisp
(setq org-startup-indented t)
(setq org-indent-mode t)
#+END_SRC

*** Sin barra cli
#+BEGIN_SRC emacs-lisp
(if (not window-system) (menu-bar-mode -1))
#+END_SRC
*** Sin barra gui
#+BEGIN_SRC emacs-lisp
(menu-bar-mode -1)
#+END_SRC

*** Diccionario spanish
#+BEGIN_SRC emacs-lisp
(setq ispell-dictionary "spanish")
#+END_SRC

*** Formatos en org-modo
#+BEGIN_SRC emacs-lisp
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(add-to-list 'auto-mode-alist '("\\.gtd\\'" . org-mode))
(add-to-list 'auto-mode-alist '("\\.txt\\'" . org-mode))
#+END_SRC

*** Aumentar, reducir texto gui
#+BEGIN_SRC emacs-lisp
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
#+END_SRC

*** Resaltar parentesis
#+BEGIN_SRC emacs-lisp
(show-paren-mode 1)
#+END_SRC

*** Transparencia en el buffer
#+BEGIN_SRC emacs-lisp
;(set-frame-parameter (selected-frame) 'alpha '(85. 50))
;(add-to-list 'default-frame-alist '(alpha . (85 50)))
#+END_SRC

*** Actualizar ficheros
#+BEGIN_SRC emacs-lisp
 (global-auto-revert-mode 1)
#+END_SRC

*** Reusar buffers dired
#+BEGIN_SRC emacs-lisp
(with-eval-after-load 'dired
  (define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file))
#+END_SRC

*** Sin copias
#+BEGIN_SRC emacs-lisp
(setq make-backup-files nil)
(setq auto-save-default nil)
#+END_SRC

*** Mostrar fecha y hora
#+BEGIN_SRC emacs-lisp
(setq display-time-day-and-date t
      display-time-24hr-format t)
(display-time)
#+END_SRC

*** Insensible busquedas
#+BEGIN_SRC emacs-lisp
(setq case-fold-search nil)
#+END_SRC

*** Batería
#+BEGIN_SRC emacs-lisp
(display-battery-mode 1)
#+END_SRC

*** Scroll
#+BEGIN_SRC emacs-lisp
(require 'smooth-scrolling)
(setq smooth-scroll-margin 10)
#+END_SRC

*** Espacios
#+BEGIN_SRC emacs-lisp
(add-hook 'before-save-hook 'delete-trailing-whitespace)
#+END_SRC

*** Utf-8
#+BEGIN_SRC emacs-lisp
(set-charset-priority 'unicode)
(setq locale-coding-system   'utf-8)   ; pretty
(set-terminal-coding-system  'utf-8)   ; pretty
(set-keyboard-coding-system  'utf-8)   ; pretty
(set-selection-coding-system 'utf-8)   ; please
(prefer-coding-system        'utf-8)   ; with sugar on top
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))
#+END_SRC

*** Oculta dot
#+BEGIN_SRC emacs-lisp
(add-hook 'dired-mode-hook 'dired-hide-details-mode)
#+END_SRC

*** Auto identación
#+BEGIN_SRC emacs-lisp
(global-set-key (kbd "RET") 'newline-and-indent)
#+END_SRC

*** Inhibir mensajes inicio
#+BEGIN_SRC emacs-lisp
(setq inhibit-startup-buffer-menu t)
(setq inhibit-startup-screen t)
(setq inhibit-startup-message t)
(setq inhibit-startup-echo-area-message "Gnuser")
#+END_SRC

*** Upper lower
#+begin_src emacs-lisp
  (put 'downcase-region 'disabled nil)
  (put 'upcase-region 'disabled nil)
#+end_src

*** Save localizacion
#+begin_src emacs-lisp
  (save-place-mode t)
#+end_src

** Ajuste Paquetes
*** Emms
#+BEGIN_SRC emacs-lisp
(require 'emms-setup)
(emms-standard)
(emms-default-players)
(setq emms-source-file-default-directory "~/Music/")
#+END_SRC

*** Eww
#+BEGIN_SRC emacs-lisp
(setq browse-url-browser-function 'eww-browse-url)
#+END_SRC

*** Feed
#+BEGIN_SRC emacs-lisp
(setq elfeed-feeds
      '(
        "http://www.muylinux.com/feed/"
        "https://www.parabola.nu/feeds/news/"
        "https://victorhckinthefreeworld.com/feed/"
        "https://mierda.tv/feed/"
        "https://elbinario.net/feed/"
        "https://www.hyperbola.info/feeds/packages/"
        "http://blog.chuidiang.com/feed/"
        "http://blog.desdelinux.net/feed/"
        "http://blogubuntu.com/feed"
        "http://carlini.es/feed/"
        "http://cucarachasracing.blogspot.com/feeds/posts/default?alt=rss"
        "http://ea4bns.blogspot.com/feeds/posts/default"
        "http://elarmarioinformatico.blogspot.com/feeds/posts/default"
        "http://elblogdeliher.com/feed/"
        "http://enavas.blogspot.com/feeds/posts/default?alt=rss"
        "http://es.xkcd.com/rss/"
        "http://feeds.feedburner.com/blogspot/bytelearning"
        "http://feeds.feedburner.com/btroot?format=xml"
        "http://feeds.feedburner.com/diegocg?format=xml"
        "http://feeds.feedburner.com/Esbuntucom?format=xml"
        "http://feeds.feedburner.com/GabuntuBlog"
        "http://feeds.feedburner.com/Gambas2MisProgramas?format=xml"
        "http://feeds.feedburner.com/geeklandlinux"
        "http://feeds.feedburner.com/SYSADMIT?format=xml"
        "http://feeds.feedburner.com/teknoplof/muQI?format=xml"
        "http://feeds.feedburner.com/Ubunlog?format=xml"
        "http://feeds.feedburner.com/ugeek"
        "http://feeds.feedburner.com/ugeekblog"
        "http://feeds.feedburner.com/UnBrutoConDebian?format=xml"
        "http://feeds.weblogssl.com/genbetadev"
        "http://fernand0.github.io/feed.xml"
        "http://hackingthesystem4fun.blogspot.com/feeds/posts/default"
        "http://humanos.uci.cu/feed/"
        "http://lamiradadelreplicante.com/feed/"
        "http://linuxmanr4.com/feed/"
        "http://maslinux.es/feed/"
        "http://mhyst.es/blogs/index.php?tempskin=_rss2"
        "http://misnotaslinux.blogspot.com/feeds/posts/default"
        "http://nasciiboy.github.io/index.xml"
        "http://nosturi.es/feed/"
        "http://papermint-designs.com/roor/rss.xml"
        "http://parceladigital.com/feed/"
        "http://planet.emacsen.org/atom.xml"
        "http://quijotelibre.com/feed/"
        "http://radioela.org/spip.php?page=backend"
        "http://ranchoelectronico.org/feed/"
        "http://red-orbita.com/?feed=rss2"
        "http://rufianenlared.com/feed/"
        "http://softwarelibre.deusto.es/feed/"
        "http://www.blackhats.es/wordpress/?feed=rss2"
        "http://www.decrecimiento.info/feeds/posts/default"
        "http://www.eldiario.es/rss/hojaderouter/"
        "http://www.hackplayers.com/feeds/posts/default?alt=rss"
        "http://www.jgimenez.info/feed/"
        "http://www.kdeblog.com/feed/"
        "http://www.lapipaplena.net/feed/"
        "http://www.linuxadictos.com/feed"
        "http://www.linuxhispano.net/feed/"
        "http://www.maxxcan.com/feed/"
        "http://www.muylinux.com/feed/"
        "http://www.radioela.org/spip.php?page=backend-auteur&id_auteur=115"
        "http://www.rafaelrojas.net/feed/"
        "http://www.rootzilopochtli.com/feed/"
        "http://www.tomatesasesinos.com/feed/"
        "http://www.tomatuordenador.net/feed/"
        "http://www.ubuntizando.com/feed/"
        "https://andalinux.wordpress.com/feed/"
        "https://aprendizdesysadmin.com/feed/"
        "https://asm86.wordpress.com/feed/"
        "https://autodefensainformatica.radioalmaina.org/feed/"
        "https://birrasybits.wordpress.com/feed/"
        "https://blog.adrianistan.eu/feed/"
        "https://blog.gvsig.org/feed/"
        "https://cartaslinux.wordpress.com/feed/"
        "https://ciberlatino.wordpress.com/feed/"
        "https://codingornot.com/feed"
        "https://colaboratorio.net/feed/"
        "https://compilando.audio/index.php/feed/podcast/"
        "https://comunicatelibremente.wordpress.com/feed/"
        "https://diariodeunalinuxera.com/feed/"
        "https://duglasm.wordpress.com/feed/"
        "https://elbinario.net/feed/"
        "https://elblogdecarlosvelasco.wordpress.com/feed/"
        "https://eliasbrasa.wordpress.com/feed/"
        "https://eliotreyna.blogspot.com/feeds/posts/default"
        "https://elpinguinotolkiano.wordpress.com/feed/"
        "https://elzorrolibre.noblogs.org/feed/"
        "https://enekoamieva.com/blog/feed/"
        "https://feedpress.me/podcastlinux"
        "https://gutl.jovenclub.cu/feed/"
        "https://h4ckseed.wordpress.com/feed/"
        "https://infostatex.blogspot.com/feeds/posts/default"
        "https://jummp.wordpress.com/feed/"
        "https://jvare.com/feed/"
        "https://kernelpanicblog.wordpress.com/feed/"
        "https://laenredadera.net/feed/"
        "https://lapastillaroja.net/feed/"
        "https://lasindias.net/feed"
        "https://leninmhs.wordpress.com/feed/"
        "https://lignux.com/feed/"
        "https://linuxgnublog.org/es/feed"
        "https://mierda.tv/feed/"
        "https://miguelpinia.wordpress.com/feed/"
        "https://milagrosrp.wordpress.com/feed/"
        "https://mx.ivoox.com/es/podcast-podcast-el-precipicio_fg_f176717_1.xml"
        "https://mx.ivoox.com/es/podcast-podcast-kde-espana_fg_f1249423_1.xml"
        "https://mx.ivoox.com/es/reality-cracking_fg_f159955_filtro_1.xml"
        "https://www.ivoox.com/podcast-fran-casas_fg_f1449982_1.xml"
        "https://www.ivoox.com/podcast-podcast-verne-wells-ciencia-ficcion_fg_f1100419_1.xml"
        "https://neoranger.github.io/feed.xml"
        "https://noelonassis.wordpress.com/blog/feed/"
        "https://ondahostil.wordpress.com/feed/"
        "https://otroespacioblog.wordpress.com/feed/"
        "https://pfctelepathy.wordpress.com/feed/"
        "https://picodotdev.github.io/blog-bitix/index.xml"
        "https://poesiabinaria.net/feed/"
        "https://radioslibres.net/rss/"
        "https://thelinuxalchemist.wordpress.com/feed/"
        "https://victorhckinthefreeworld.com/feed/"
        "https://vidaembebida.wordpress.com/feed/"
        "https://www.atareao.es/blog/feed/"
        "https://www.cambiadeso.es/feed/"
        "https://www.linuxito.com/?format=feed&type=rss"
        "https://www.ochobitshacenunbyte.com/feed/"
        "https://xkcd.com/rss.xml"
        "https://xnet-x.net/blog/feed/"
        "https://conocimientoslibres.tuxfamily.org/feeds/"
        "https://www.hyperbola.info/feeds/"
        ))
#+END_SRC

*** Autopair
#+BEGIN_SRC emacs-lisp
(require 'autopair)
(autopair-global-mode)
#+END_SRC

*** Erc
#+BEGIN_SRC emacs-lisp
(setq erc-interpret-mirc-color t)
(setq erc-nick "bzp"
      erc-server-auto-reconnect t
      erc-server-reconnect-timeout 15)
(setq erc-autojoin-channels-alist '(("freenode.net" "#emacs-es" "#hyperbola")))
(add-to-list 'auth-sources "~/.authinfo")
#+END_SRC

*** Rainbow
#+BEGIN_SRC emacs-lisp
    (use-package rainbow-mode
      :hook
      (css-mode  . rainbow-mode)
      (sass-mode . rainbow-mode)
      (scss-mode . rainbow-mode)
      (less-mode . rainbow-mode)
      (web-mode  . rainbow-mode)
      (emacs-lisp-mode  . rainbow-mode)
      (html-mode . rainbow-mode))
    (provide 'init-rainbow)
#+END_SRC
*** Gnus
#+BEGIN_SRC emacs-lisp
     (setq gnus-select-method
           '(nnimap "mail.cock.li"))
#+END_SRC

*** COMMENT Exwm
# +BEGIN_SRC emacs-lisp
(require 'exwm)
(require 'exwm-config)
(exwm-config-default)

(require 'exwm-randr)
(setq exwm-randr-workspace-output-plist '(1 "DP-1"))
(add-hook 'exwm-randr-screen-change-hook
          (lambda ()
            (start-process-shell-command
             "xrandr" nil "xrandr --output DP-1 --right-of DP-2 --auto")))
(exwm-randr-enable)

(require 'exwm-systemtray)
(exwm-systemtray-enable)
# +END_SRC

*** Magit
#+BEGIN_SRC emacs-lisp
(global-set-key (kbd "C-x g") 'magit-status)
#+END_SRC

*** Bullets
# +BEGIN_SRC emacs-lisp
(require 'org-bullets)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
# +END_SRC

*** Export pdf
#+BEGIN_SRC emacs-lisp
(require 'ps-print)
(when (executable-find "ps2pdf")
  (defun modi/pdf-print-buffer-with-faces (&optional filename)
    "Print file in the current buffer as pdf, including font, color, and
underline information.  This command works only if you are using a window system,
so it has a way to determine color values.

C-u COMMAND prompts user where to save the Postscript file (which is then
converted to PDF at the same location."
    (interactive (list (if current-prefix-arg
                           (ps-print-preprint 4)
                         (concat (file-name-sans-extension (buffer-file-name))
                                 ".ps"))))
    (ps-print-with-faces (point-min) (point-max) filename)
    (shell-command (concat "ps2pdf " filename))
    (delete-file filename)
    (message "Deleted %s" filename)
    (message "Wrote %s" (concat (file-name-sans-extension filename) ".pdf"))))
#+END_SRC

*** Markdown
#+BEGIN_SRC emacs-lisp
;;(add-to-list 'load-path "~/.emacs.d/elpa/markdown-mode-2.0")
(autoload 'markdown-mode "markdown-mode" t)
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
#+END_SRC

*** Pandoc markdown
#+BEGIN_SRC emacs-lisp
(load "pandoc-mode")
(add-hook 'markdown-mode-hook 'pandoc-mode)
#+END_SRC

** Short cuts
*** Compilar groff
#+begin_src emacs-lisp
(defun my-nroff-mode-set-compile-command ()
(when buffer-file-name
  (let* ((output-path (concat (file-name-sans-extension buffer-file-name)
                             ".pdf")))
   (setq-local compile-command
             (format "time groff -ms . %s -Tps -k -t | ps2pdf - %s"
                       (shell-quote-argument buffer-file-name)
                        (shell-quote-argument output-path))))))

 (add-hook 'nroff-mode-hook 'my-nroff-mode-set-compile-command)

(with-eval-after-load 'nroff-mode
   (define-key nroff-mode-map (kbd "<f5>") 'compile))
#+end_src

#+begin_src emacs-lisp
;(defun compile-ms-file ()
;  (interactive)
;  (let ((command (format "time groff -ms . %s -Tps -k -t | ps2pdf - /tmp/out.pdf" (buffer-file-name))))
;    (compile command)))

;(with-eval-after-load 'nroff-mode
;  (define-key nroff-mode-map (kbd "<f5>") 'compile-ms-file))
#+END_SRC

*** Compilar java
#+begin_src emacs-lisp
(require 'compile)
(global-set-key (kbd "<f5>") 'compile)
(setq compile-command "javac ")
#+end_src

***Numerar linea
#+BEGIN_SRC emacs-lisp
(require 'linum)
(global-set-key (kbd "<f6>") 'linum-mode)
(setq linum-format "%d  ")
#+END_SRC

*** Resaltar linea
#+begin_src emacs-lisp
(require 'hl-line)
(global-set-key (kbd "<f7>") 'hl-line-mode)
#+end_src

*** Compilacion
#+begin_src emacs-lisp
;(require 'compile)
;(global-set-key (kbd "<f8>") 'compile)
;(setq compile-command "javac ")
#+end_src

* Lenguajes
** Org-mode
*** Config org
#+BEGIN_SRC emacs-lisp
(require 'org-install)
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(define-key global-map "\C-cc" 'org-capture)
(define-key global-map "\C-cb" 'org-switchb)
(setq org-log-done t)
#+END_SRC

*** Agenda org
#+BEGIN_SRC emacs-lisp
(setq org-agenda-files (list "~/Documents/TrabajosUbi/Work-Me/Recursos/DiarioOrgMode/AgendaMe.org"))
#+END_SRC

*** Plantillas orgmode
#+BEGIN_SRC emacs-lisp
(defun org-mode-insert-header (language)
   "Make a template at point."
   (interactive
    (let ((languages '("Generic" "HTML" "LaTeX" )))
      (list (ido-completing-read "To which export: " languages)
      )))

   (when (string= language "Generic")
     (progn
       (insert (format "#+title:\n"))
       (insert (format "#+author:\n"))
       (insert (format "#+language: es \n"))
       (insert (format "#+options: toc:1 \\n:t ^:nil\n"))
       (insert (format "#+toc: headlines 3\n\n"))
       ))

   (when (string= language "HTML")
     (progn
       (insert (format "#+title:\n"))
       (insert (format "#+author:\n"))
       (insert (format "#+language: es\n"))
       (insert (format (concat "#+setupfile: ~/Documents/TrabajosMe/GnuFull/OrgMode/srch/SetupHtml.txt\n\n")))
       ))
   (when (string= language "LaTeX")
     (progn
       (insert (format "#+title:\n"))
       (insert (format "#+author:\n"))
       (insert (format "#+language: es\n"))
       (insert (format (concat "#+setupfile: ~/Documents/TrabajosMe/GnuFull/OrgMode/srcl/SetupLatex.txt\n\n")))
       )))
#+END_SRC

** Babel
*** Lenguajes soportados
#+BEGIN_SRC emacs-lisp
(org-babel-do-load-languages
 'org-babel-load-languages
 '(
   (dot        . t)
   (lisp       . t)
   (gnuplot    . t)
   (latex      . t)
   (ledger     . t)
   (python     . t)
   (sh         . t)
   (sql        . t)
   (sqlite     . t)
   (js         . t)
   (emacs-lisp . t)
   (perl       . t)
   ;(scala      . t)
   (clojure    . t)
   (ruby       . t)
   (dot        . t)
   (css        . t)
   (plantuml   . t)
   (C          . t)
   (java       . t)
   (R          . t)
   (haskell    . t)
   (calc       . t)
   ))
#+END_SRC

*** Evaluar si preguntar
#+BEGIN_SRC emacs-lisp
(setq org-confirm-babel-evaluate nil)
#+END_SRC

** Web
#+BEGIN_SRC emacs-lisp
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))

(setq web-mode-enable-auto-closing t)

(setq web-mode-enable-css-colorization t)
(setq web-mode-enable-block-face t)

(add-hook 'web-mode-hook 'emmet-mode)

(setq web-mode-engines-alist
      '(("php"    . "\\.phtml\\'")
        ("blade"  . "\\.blade\\.")))

(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))

(setq web-mode-code-indent-offset 2)
#+END_SRC

** Php
#+BEGIN_SRC emacs-lisp
(autoload 'php-mode "php-mode" "Major mode for editing PHP code." t)
(add-to-list 'auto-mode-alist '("\\.php$" . php-mode))
(add-to-list 'auto-mode-alist '("\\.inc$" . php-mode))
#+END_SRC

* COMMENT Comandos [62%]
Esta seccion no es imprimible, solo servira para referencias de los comandos que
se utiliza frecuentemente. El comando COMMENT C-c ; (Comentario) no es implimible en
latex.

Propiedades, estoy aprendiendo aun.
  # :PROPERTIES:
  # :ORDERED:  t
  # :END:

Los Checkbox son utiles, funcionan co TODO y se puede mostrar el avance en % o
cantidad de numeros. Cada Checkbox a la derecha se describe lo que hace y la
combinancion de teclas.

+ [X] Comentarios: C-c ;
+ [X] Todo: Shift- ->
+ [X] Deadline: C-c C-d
+ [X] Schelude: C-c C-s
+ [ ] Start Clock: C-c C-x C-i
+ [ ] Stop Clock: C-c C-x C-o
+ [ ] Propiedades: C-c C-x o
+ [ ] Asigna Propiedad: C-c C-x p
+ [X] Checkbox: C-c C-c
+ [X] Insertar imagen: C-u C-c C-l
+ [ ] Etiquetas: C-c C-q
+ [X] Insertar fecha: C-c .
+ [X] Evaluar: C-c C-c
+ [ ] Ejecutar: C-c '
+ [X] Bloque codigo: <s tab
+ [X] Propiedad: Shift-up
+ [ ] Cambiar bullets: Shift-right
+ [ ] Nota al pie: C-c C-x f

** Ecuaciones
#+BEGIN_LaTeX
\begin{equation}
k_1=hf_{(x_0,y_0)};k_2=hf_{(x_0+\frac{h}{2},y_0+\frac{k_1}{2})};k_3=hf_{(x_0+\frac{h}{2},y_0+\frac{k_2}{2})};k_4=hf_{(x_0+h,y_0+k_3)} \label{ec02}
\end{equation}
#+END_LaTeX

** Evaluar codigo
Los bloques de codigo son utiles para evaluar, para crear un bloque se realiza
con la combinacion de teclas <s+tab

+ Este ejemplo es para mostrar todos los registro de la tabla xxx, es una forma
  de evaluar bloques de comandos desde org-mode con babel. Para evaluar un
  bloque usar: C-c C-c.

#+srcname: MariadbEjemplo01
#+begin_src sql :engine mysql :cmdline -h 127.0.0.1 -u usuario -pusuario -D Practica001
select * from tabla
#+end_src

+ Evalua un bloque de codigo del lenguaje elisp de emacs, se observa en results
  el resultado de la evaluacion.

#+begin_src emacs-lisp
  (+ 1 2 3 4)
#+end_src

#+RESULTS:
: 10

+ Para evaluar un bloque usar: C-c C-c
#+RESULTS:
: 10

#+BEGIN_SRC python :results output
  import random
  random.seed(1)
  print("Hello World! Here's a random number: %f" % random.random())
#+END_SRC

#+BEGIN_SRC sh
ls ~/
#+END_SRC

#+BEGIN_SRC sh
pwd
#+END_SRC

#+BEGIN_SRC sh :results raw
ls ~
/
#+END_SRC

#+BEGIN_SRC sh :dir /
ls
#+END_SRC

#+BEGIN_SRC sh :dir ~
ls
#+END_SRC

#+begin_src C
  printf ("Hello World!\n");
#+end_src

#+name: tbl-example-data
#+begin_src R
runif(n=5, min=0, max=1)
#+end_src

#+BEGIN_SRC haskell
let x = 1 in x + x
#+END_SRC

** Cifrado con Epa-Gpg
  En emacs 2019 Elpa

*** Cifrar region
   M-x epa-encrypt-region

*** Decifrar region
   M-x epa-decrypt-region

*** Cifrado desde Dired
:e Cifrar
:d Descifrar
:v Verificar
:s Firmar

** Enlaces

#+caption: Descripcion de la imagen
#+attr_latex:  :placement [t] :width 90px :options angle=0
#+label: fig.super
[[file:~/Documents/TrabajosUbi/Work-Me/04Sem/Analisis02/PracticaAna02/img/EditorialProyecto02.png]]

#+caption: Titulo de la tabla
#+name:   tab:basic-data
|----+-----------+----------+--------+-------|
| Id | Detalle   | Cantidad | Precio | Total |
|----+-----------+----------+--------+-------|
| 01 | Monitores |       10 |     80 |   300 |
| 02 | Cpu's     |        2 |    100 |   200 |

** Options header
#+BEGIN_LaTeX
H:         set the number of headline levels for export
num:       turn on/off section-numbers
toc:       turn on/off table of contents, or set level limit (integer)
\n:        turn on/off line-break-preservation (DOES NOT WORK)
@:         turn on/off quoted HTML tags
::         turn on/off fixed-width sections
|:         turn on/off tables
^:         turn on/off TeX-like syntax for sub- and superscripts.  If you write "^:{}", a_{b} will be interpreted, but the simple a_b will be left as it is.
-:         turn on/off conversion of special strings.
f:         turn on/off footnotes like this[1].
todo:      turn on/off inclusion of TODO keywords into exported text
tasks:     turn on/off inclusion of tasks (TODO items), can be nil to remove  all tasks, todo to remove DONE tasks, or list of kwds to keep
pri:       turn on/off priority cookies
tags:      turn on/off inclusion of tags, may also be not-in-toc
<:         turn on/off inclusion of any time/date stamps like DEADLINES
*:         turn on/off emphasized text (bold, italic, underlined)
TeX:       turn on/off simple TeX macros in plain text
LaTeX:     configure export of LaTeX fragments.  Default auto
skip:      turn on/off skipping the text before the first heading
author:    turn on/off inclusion of author name/email into exported file
email:     turn on/off inclusion of author email into exported file
creator:   turn on/off inclusion of creator info into exported file
timestamp: turn on/off inclusion creation time into exported file
d:         turn on/off inclusion of drawers
#+END_LaTeX
** Referencias
Referencias de emacs y org-mode en especial la segunda
- http://www.davidam.com/docu/orgguide.es.html
- http://planet.emacs-es.org/
- https://github.com/rosepac/biblioteca-espanol-gratis/blob/master/libros-programacion-gratis.md

* Footnotes
[fn:1] Gnu not unix, sistema operativo tipo unix inicialmente propuesto y desarrollado por el Dr. en fisica Richard Mathews Stallman (RMS).

[fn:2] Programas que promueven las cinco libertades difundidas RMS y la FSF.
